﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="eTruck.Views.Users.List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="<%=Page.ResolveClientUrl("~/Styles/Site.css")%>" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="<%=Page.ResolveClientUrl("~/Styles/ss.gridview.css")%>"/>
    <link rel="stylesheet" type="text/css" href="<%=Page.ResolveClientUrl("~/Styles/themes/default/easyui.css")%>"/>
	<link rel="stylesheet" type="text/css" href="<%=Page.ResolveClientUrl("~/Styles/themes/icon.css")%>"/>
	<script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/jquery.min.js")%>"></script>
	<script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/jquery.easyui.min.js")%>"></script>
    <script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/CheckBox.js")%>"></script>
    <script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/ss.changebackground.js")%>"></script>
<script language="javascript" src="Form.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('#dlg').dialog('close')
    });
</script>
<script type="text/javascript">

    //add:0;modify:1;detail:2=>type
    function showDivObj(control, type) {


        $("input[id*='txtUserName']").removeAttr("disabled");
        $("input[id*='txtFirstName']").removeAttr("disabled");
        $("input[id*='txtLastName']").removeAttr("disabled");
        $("input[id*='txtEmailAddress']").removeAttr("disabled");
        $("input[id*='txtPhone']").removeAttr("disabled");
        $("input[id*='txtDepartMent']").removeAttr("disabled");

        $("#btnSubmit").show();

        if (type == 0) {
            $("input[id*='txtUserID']").val("");
            $("input[id*='txtUserName']").val("");
            $("input[id*='txtFirstName']").val("");
            $("input[id*='txtLastName']").val("");
            $("input[id*='txtEmailAddress']").val("");
            $("input[id*='txtPhone']").val("");
            $("input[id*='txtDepartMent']").val("");
        }
        else {
            var trItem = $("#" + control.id).closest("tr");
            $("input[id*='txtUserID']").val(trItem.find("input[type=hidden][id*='key']").val());
            $("input[id*='txtUserName']").val(trItem.children("td").eq(1).html());
            $("input[id*='txtFirstName']").val(trItem.children("td").eq(2).html());
            $("input[id*='txtLastName']").val(trItem.children("td").eq(3).html());
            $("input[id*='txtEmailAddress']").val(trItem.children("td").eq(4).html());
            $("input[id*='txtPhone']").val(trItem.children("td").eq(5).html());
            $("input[id*='txtDepartMent']").val(trItem.children("td").eq(6).html());
            if (type == 2) {
                $("input[id*='txtFirstName']").attr("disabled", "disabled");
                $("input[id*='txtLastName']").attr("disabled", "disabled");
                $("input[id*='txtEmailAddress']").attr("disabled", "disabled");
                $("input[id*='txtPhone']").attr("disabled", "disabled");
                $("input[id*='txtDepartMent']").attr("disabled", "disabled");

                $("#btnSubmit").hide();
            }
            $("input[id*='txtUserName']").attr("disabled", "disabled");
        }

        $('#dlg').dialog('open');
        return false;
    }

</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width: 100%;" cellpadding="2" cellspacing="1" class="border">
                <tr>
                    <td style="width: 80px" align="right" class="tdbg">
                         <b>关键字：</b>
                    </td>
                    <td class="tdbg">                       
                    <asp:TextBox ID="txtKeyword" runat="server"></asp:TextBox>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnSearch" runat="server" Text="查询"  OnClick="btnSearch_Click" >
                    </asp:Button>                    
                        
                    </td>
                    <td class="tdbg">
                    </td>
                </tr>
            </table>
            <!--Search end-->
            <br />
            <table border="0" cellpadding="0" cellspacing="1" style="width: 100%;">
                <tr>
                    <td style="width: 1px;">                        
                    </td>
                    <td align="left">
                        <asp:Button ID="btnDelete" runat="server" Text="删除" OnClick="btnDelete_Click"/>  
                        <input type="button" id="btnAdd" name="add" value="添加" onclick="showDivObj(this,0)" />                    
                    </td>
                </tr>
            </table>
            <asp:GridView ID="gridView" runat="server" AllowPaging="True" Width="100%" CellPadding="3"  OnPageIndexChanging ="gridView_PageIndexChanging"
                    BorderWidth="1px" DataKeyNames="UserID" OnRowDataBound="gridView_RowDataBound" OnRowCommand="gridView_RowCommand"
                    AutoGenerateColumns="false" PageSize="10"  RowStyle-HorizontalAlign="Center" OnRowCreated="gridView_OnRowCreated">
                    <Columns>
                    <asp:TemplateField ControlStyle-Width="30" HeaderText="选择"    >
                                <ItemTemplate>
                                    <asp:CheckBox ID="DeleteThis" onclick="javascript:CCA(this);" runat="server" />
                                    <asp:HiddenField ID="key" runat="server" Value='<%#Eval("UserID") %>' />
                                </ItemTemplate>
                            </asp:TemplateField> 
                            <asp:BoundField DataField="UserName" HeaderText="用户名" SortExpression="UserName" ItemStyle-HorizontalAlign="Center"  /> 
		                    <asp:BoundField DataField="FirstName" HeaderText="姓氏" SortExpression="FirstName" ItemStyle-HorizontalAlign="Center"  /> 
		                    <asp:BoundField DataField="LastName" HeaderText="名字" SortExpression="LastName" ItemStyle-HorizontalAlign="Center"  /> 
		                    <asp:BoundField DataField="EmailAddress" HeaderText="邮箱" SortExpression="EmailAddress" ItemStyle-HorizontalAlign="Center"  /> 
		                    <asp:BoundField DataField="Phone" HeaderText="电话" SortExpression="Phone" ItemStyle-HorizontalAlign="Center"  /> 
		                    <asp:BoundField DataField="DepartMent" HeaderText="部门" SortExpression="DepartMent" ItemStyle-HorizontalAlign="Center"  /> 
		                    <asp:BoundField DataField="LastUpdated" HeaderText="更新时间" SortExpression="LastUpdated" ItemStyle-HorizontalAlign="Center"  /> 
                            
                            <asp:TemplateField HeaderText="详细">
                            <ItemTemplate>
                                <input type="button" id="<%#Eval("UserID")%>" name="detail" value="详细" onclick="showDivObj(this,2)" />
                            </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="编辑">
                                <ItemTemplate>
                                    <input type="button" id="<%#Eval("UserID")%>" name="modify" value="编辑" onclick="showDivObj(this,1)" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:ButtonField ButtonType="Button" CommandName="DeleteRow" Text="删除" HeaderText="删除" />
                        </Columns>
                        <HeaderStyle CssClass="ss_gv_title"/>
                </asp:GridView>
               
             <div id="dlg" class="easyui-dialog" title="用户信息" style="width: 400px;
                height: 350px; padding: 10px">
                <table>
                    <tr>
                        <td class="ss_form_name">
                            用户名:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtUserName" runat="server" Width="200px" MaxLength="30" onblur="UserNameCheck(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            姓氏:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtFirstName" runat="server" Width="200px" MaxLength="10" onblur="NameCheck(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            名字:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtLastName" runat="server" Width="200px" MaxLength="10" onblur="NameCheck(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            邮箱:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtEmailAddress" runat="server" Width="200px" MaxLength="30" onblur="EmailCheck(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            电话:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtPhone" runat="server" Width="200px" MaxLength="10" onblur="PhoneCheck(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            部门:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtDepartMent" runat="server" Width="200px" MaxLength="10"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div style=" visibility:hidden;">
                                <asp:TextBox ID="txtUserID" runat="server" />
                            </div>
                        </td>
                    </tr>
                </table>
                <input type="button" id="btnSubmit" name="submit" value="确定" onclick="submit()"/>
                <asp:Button ID="Button2" runat="server" Text="取消" OnClientClick=" $('#dlg').dialog('close')" />
            </div>
    </div>
    </form>
</body>
</html>
